home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Speccy ClassiX 1998
/
Speccy ClassiX 98.iso
/
amiga_system
/
the_aminet
/
comm
/
bbs
/
maxsutils.lha
/
MaxUtils
/
Maxcps54.lha
/
MaxCPS.S
< prev
next >
Wrap
Text File
|
1993-04-14
|
12KB
|
541 lines
;--------------------------------------------------------------------
;
; -----------------
; ** M A X C P S **
; ** V1.54 **
; -----------------
;
; Program to Calculate the Top Transfers Speeds
;
; of People Downloading Files from MaxsBBS V1.52
;
;
; Written by: Greg MacDonald
; Using: Devpac 3
; Date: 12-April-1993
;
; Version 1.54
;
;--------------------------------------------------------------------
Opt C-
InitOffSet = 281 ;OffSet to Start of Area in
;ANSI screen to start printing
LineOffSet = 65 ;Distance from one line to the
;next in the ansi text
AllTimeOffSet = 1027-16 ;OffSet for All Time Highest
;CPS
NumLog = 20 ;Number of Download to Check Back
;thru
MaxCPS: bsr OpenDos ;Open Dos Library
tst.l d0
beq.s Exit1
bsr LoadAnsi ;Load Ansi Screen if Available
bsr ExamineFile ;Examine Download Log Size
tst.l d0
beq.s Exit2
bsr AllocMem ;Allocate Mem for Dload Log
tst.l d0
beq.s Exit2
bsr LoadLog ;Load Dload Log to Memory
cmp.l #-1,d0
beq.s Exit3
bsr StartLog ;Find Start of Last X Entries
bsr GetMaxCPS ;Find MAX CPS Values
bsr GetNames ;Get Names for Max CPS Values
bsr AllTimeBest
bsr SaveFile ;Save Out Ansi Screen
cmp.l #-1,d0
beq.s Exit3
Nop
Exit3: bsr DeAllocMem
Exit2: bsr CloseDos
Exit1: moveq #0,d0
rts
dc.b '$VER:MAXCPS 1.54 (14.4.93)',10
dc.b 'By Greg MacDonald',10
dc.b 'Call ENCONN BBS +61-2-5241584',10,0
Even
;--------------------------------------------------------------------
;
; Open Dos Library and Get Base Address
;
;--------------------------------------------------------------------
DosBase: dc.l 0 ;Base Address of Dos Library
DosName: dc.b 'dos.library',0
Even
OpenDos: moveq #0,d0
Lea DosName(pc),a1
move.l 4.w,a6
jsr -408(a6) ;Open Library
move.l d0,DosBase
rts
;--------------------------------------------------------------------
;
; Close the Dos Library
;
;--------------------------------------------------------------------
CloseDos: move.l 4.w,a6
move.l DosBase(pc),a1
jsr -414(a6) ;Close Library
rts
;--------------------------------------------------------------------
;
; Examine File for Length so we can Allocate Memory
;
;--------------------------------------------------------------------
Lock: dc.l 0 ;Lock for Download Log
Name: dc.b 'BBS:LogFiles/DnLoadLog.Text',0
ds.b 22
Even
ExamineFile: moveq #-2,d2
move.l #Name,d1
move.l DosBase(pc),a6
jsr -84(a6) ;Lock
move.l d0,d1
beq.s ExamineError
move.l d0,Lock
move.l #FileInfoBlock,d2
jsr -102(a6) ;Examine
move.l d0,-(a7) ;Save for a Sec
move.l Lock(pc),d1
jsr -90(a6) ;UnLock
move.l (a7)+,d0
ExamineError: rts
;--------------------------------------------------------------------
;
; Alocates Memory for Loading in Download Log
;
;--------------------------------------------------------------------
MemBase: dc.l 0 ;Address of Download Log
MemSize: dc.l 0 ;Size of Download Log
AllocMem: move.l 4.w,a6
lea FileInfoBlock,a0
move.l 124(a0),d0
move.l d0,MemSize
tst.l d0
beq.s AllocError
moveq #0,d1
jsr -198(a6) ;Allocate Memory
move.l d0,MemBase
AllocError: rts
;--------------------------------------------------------------------
;
; De-Allocated Memory for Loading in Download Log
;
;--------------------------------------------------------------------
DeAllocMem: move.l 4.w,a6
move.l MemBase(pc),a1
move.l MemSize(pc),d0
jsr -210(a6) ;Free Memory
rts
;--------------------------------------------------------------------
;
; Load Download Log Into Memory
;
;--------------------------------------------------------------------
FileHandle: dc.l 0 ;File Handle For Log File
LoadLog: move.l DosBase(pc),a6
move.l #Name,d1
move.l #1005,d2 ;Read Only
jsr -30(a6) ;Open File
move.l d0,FileHandle
tst.l d0
beq.s LoadError
move.l d0,d1 ;Handle
move.l MemBase(pc),d2
move.l MemSize(pc),d3
jsr -42(a6) ;Read File
move.l d0,-(a7) ;Save For a Sec
move.l FileHandle(pc),d1
jsr -36(a6) ;Close File
move.l (a7)+,d0
rts
LoadError: moveq #-1,d0
rts
;--------------------------------------------------------------------
;
; Save OutPut File to RAM
;
;--------------------------------------------------------------------
SaveName: dc.b 'Ram:MaxsFiles/MaxCPS.Ansi',0
ds.b 50-27
Even
SaveFile: move.l DosBase(pc),a6
move.l #SaveName,d1
move.l #1006,d2
jsr -30(a6) ;Open File
move.l d0,FileHandle
move.l d0,d1
beq.s SaveError
move.l #SaveBuffer,d2
move.l #EndSave-SaveBuffer,d3 ;Length to Save
jsr -48(a6)
move.l d0,-(a7) ;Save for Later
move.l FileHandle(pc),d1
jsr -36(a6) ;Close File
move.l (a7)+,d0
rts
SaveError: moveq #-1,d0
rts
;--------------------------------------------------------------------
;
; Get to Start of Last "NumLog" Downloads
;
;--------------------------------------------------------------------
StartLog: move.l MemBase(pc),a0
move.l a0,a6
add.l MemSize(pc),a6 ;End of Log File
moveq #0,d7 ;Counter
SearchLog: cmp.l a0,a6
ble.s EndLog
cmp.b #$0a,(a6)
beq.s FoundReturn
RetFound: subq.w #1,a6
bra.s SearchLog
EndLog: move.l MemBase(pc),StartBase
rts
FoundReturn: addq.w #1,d7
cmp.w #NumLog+1,d7
blt.s RetFound
move.l a6,StartBase
rts
StartBase: dc.l 0 ;Where to Start Looking
;For Download CPS Values
;--------------------------------------------------------------------
;
; Get 10 Highest CPS from DownLoad Log File
;
;
; Search for a ", " the cps value is after that and is
; terminated by a return (10 decimal).
;
; What this does first is go thru the log file and collects
; all the cps values and finds the current 10 highest
;
;--------------------------------------------------------------------
CPSNUM: dc.w -1 ;How Many CPS Added
GetMaxCPS: move.l MemBase(pc),a0
move.l a0,a6
add.l MemSize(pc),a6 ;End of Log File
move.l StartBase(pc),a0
MaxLoop1: move.b (a0),d0
cmp.b #',',d0
beq.s FoundCPS
addq.w #1,a0
cmp.l a0,a6
bgt.s MaxLoop1
rts
FoundCPS: addq.w #2,a0 ;Get to CPS Value
move.l a0,a5 ;Keep Address
move.l #$20202020,d0 ;All Spaces
moveq #4,d7 ;Max CPS is 9999
FoundCPS2: move.b (a0)+,d1
cmp.b #10,d1 ;Return
beq.s FoundCPS3
lsl.l #8,d0
move.b d1,d0
dbf d7,FoundCPS2
bra.s MaxLoop1 ;Must have been No Return
FoundCPS3: lea StoredCPS,a1
moveq #-1,d7
FoundCPS4: addq.w #1,d7
cmp.l (a1),d0
bge.s NewCPS ;UpDate CPS
add.w #12,a1 ;Down One CPS
cmp.w #9,d7
blt.s FoundCPS4
bra.s MaxLoop1 ;CPS Too Small
NewCPS: addq.w #1,CPSNUM
moveq #10-1,d6 ;Copy Lower CPS's
lea StoredCPS+10*12,a1
sub.w d7,d6 ;Down the List
NewCPS1: sub.w #12,a1
move.l (a1),12(a1) ;CPS
move.l 4(a1),16(a1) ;Address of Name
dbf d6,NewCPS1
move.l d0,(a1)+ ;New CPS
move.l a5,(a1) ;New Address
bra MaxLoop1
;CPS Speeds Stored Highest to Lowest
StoredCPS: dcb.l 11*3,0 ;First Long Word = CPS
;2nd Long Word = Address
;--------------------------------------------------------------------
;
; Gets Names from Address Stored with StoredCPS
;
;--------------------------------------------------------------------
GetNames: lea StoredCPS+4(pc),a0 ;First Replaces CPS
moveq #10-1,d7 ;Address with that
;of the Users Name.
;---- Find Start Address of Name
Get1: move.l (a0),a1
move.l a1,4(a0) ;For End of Name Stuff
addq.w #1,a1
Get2: subq.w #1,a1
cmp.b #$0a,(a1) ;Return Character
bne.s Get2
Get3: addq.w #1,a1
moveq #0,d0
Get4: addq.w #1,a1 ;Go Forward 7 Spaces
cmp.b #' ',(a1)
bne.s Get4
addq.w #1,d0
cmp.w #6,d0
blt.s Get4
move.l a1,(a0) ;Save Start Address of Name
add.w #12,a0 ;Next Lot of Data
dbf d7,Get1
;---- Find End Address of Name
lea StoredCPS+8(pc),a0
moveq #10-1,d7
Get7: move.l (a0),a1
addq.w #1,a1
moveq #0,d0
Get8: subq.w #1,a1 ;Go Backward 3 Spaces
cmp.b #' ',(a1)
bne.s Get8
addq.w #1,d0
cmp.w #3,d0
blt.s Get8
move.l a1,(a0) ;Save End Address of Name
add.w #12,a0
dbf d7,Get7
ClearSave: lea SaveBuffer+InitOffSet,a0
moveq #$20,d0
moveq #10-1,d7
Clear1: move.w #45-1,d6
Clear2: move.b d0,(a0)+
dbf d6,Clear2
add.w #20,a0
dbf d7,Clear1
PrintNames: lea StoredCPS(pc),a0
lea SaveBuffer+InitOffSet,a6
move.w CPSNum(pc),d7
bmi.s EndPrint ;No CPS Values Added
cmp.w #10-1,d7
ble.s Print1 ;Less or = to 10-1
moveq #10-1,d7
Print1: lea LineOffSet(a6),a5 ;Next Line
move.l (a0)+,d0
move.b d0,43(a6)
lsr.l #8,d0
move.b d0,42(a6)
lsr.l #8,d0
move.b d0,41(a6)
lsr.w #8,d0
move.b d0,40(a6)
move.l (a0)+,a1 ;Start of Name Address
move.l (a0)+,a2 ;End of Name Address
moveq #36-1,d6 ;Max 35 Chars for Name
Print2: move.b (a1)+,(a6)+
cmp.l a2,a1
bge.s Print3 ;End of Name
dbf d6,Print2
Print3: move.l a5,a6
dbf d7,Print1
EndPrint: rts
;--------------------------------------------------------------------
;
; Load Pevious Ansi Screen Into Memory
;
; - If Ram:MaxsFiles/MaxCPS.Ansi exists then it's loaded
; - Else the built in Ansi screen is used
;
;--------------------------------------------------------------------
LoadAnsi: move.l DosBase(pc),a6
move.l #AnsiName,d1
move.l #1005,d2 ;Read Only
jsr -30(a6) ;Open File
tst.l d0
beq.s AnsiError
move.l d0,-(a7) ;Save Handle
move.l d0,d1 ;Handle
move.l #SaveBuffer,d2
move.l #EndSave-SaveBuffer,d3
jsr -42(a6) ;Read File
move.l (a7)+,d1 ;File Handle
jsr -36(a6) ;Close File
AnsiError: rts
AnsiName: dc.b 'ram:maxsfiles/MaxCPS.Ansi',0
SaveBuffer: Incbin Ram:MAXCPS.Text
EndSave:
;--------------------------------------------------------------------
;
; Check All Time Highest CPS Rate
;
;--------------------------------------------------------------------
AllTimeBest: lea SaveBuffer+AllTimeOffSet(pc),a0
cmp.b #'.',43(a0) ;CPS Data
beq.s NewBest
lea 40(a0),a0
bsr AsciiToHex
move.l d1,d2
lea SaveBuffer+InitOffSet+40,a0
bsr AsciiToHex
cmp.l d2,d1
bgt.s NewBest ;Equal or Higher Value
rts
;--------------------------------------------------------------------
;
; UpDate All Time Highest CPS Rate
;
;--------------------------------------------------------------------
NewBest: lea SaveBuffer+InitOffSet(pc),a0 ;Source
lea SaveBuffer+AllTimeOffSet(pc),a1 ;Destination
moveq #45-1,d7
NewBest1: move.b (a0)+,(a1)+
dbf d7,NewBest1
rts
;--------------------------------------------------------------------
;
; Converts 4 Digit Decimal Ascii to LongWord Hex sort Of.
;
; Not actually Hex, but if you compare 2 numbers got from here
; you can say one is bigger than the other
;
;--------------------------------------------------------------------
AsciiToHex: moveq #0,d1
moveq #0,d0
move.b (a0)+,d0
cmp.b #' ',d0
bne.s NoSpace1
moveq #'0',d0
NoSpace1: ror.l #8,d0
or.l d0,d1
moveq #0,d0
move.b (a0)+,d0
cmp.b #' ',d0
bne.s NoSpace2
moveq #'0',d0
NoSpace2: ror.l #8,d0
ror.l #8,d0
or.l d0,d1
moveq #0,d0
move.b (a0)+,d0
cmp.b #' ',d0
bne.s NoSpace3
moveq #'0',d0
NoSpace3: rol.l #8,d0
or.l d0,d1
moveq #0,d0
move.b (a0)+,d0
cmp.b #' ',d0
bne.s NoSpace4
moveq #'0',d0
NoSpace4: or.l d0,d1
rts
;--------------------------------------------------------------------
;
; File Info Block for Examine Command
;
; - The Setion Statement is so that it is LongWord Aligned
; - The BSS means it takes up No DiskSpace.IE All Zeros
;
;--------------------------------------------------------------------
Section FileInfoblock,BSS
FileInfoBlock: ds.l 260 ;260 Long Words of FileInfo